package src
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import gs.TweenMax;
	import gs.easing.Bounce;
	
	import nl.demonsters.debugger.MonsterDebugger;
	
	public class LookBox extends Sprite
	{
		public var ruta_mc:MovieClip;
		public var desplega:MovieClip;
		
		private var estado:Boolean = false;
		
		private var looksNames:Array = ["look1","look2","look3","look4","look5","look6","look7","look8","look9","look10"];
		
		public function LookBox()
		{
			this.buttonMode = true;
			ruta_mc.mask = mascara;
			
			ruta_mc.ruta_txt.text = '';
			
			desplega.mask = mascara_des;
			mascara_des.scaleY = 0;
			
			ruta_mc.arrow.addEventListener(MouseEvent.CLICK, clic);
			
			for(var i:int = 0; i < looksNames.length; i++)
			{
				desplega["look_"+i].texto_txt.text = looksNames[i];
				desplega["look_"+i].addEventListener(ItemLookBoxEvent.ON_LOOK_CLICK, handle_lookClick);
			}
		}
		
		public function clic (e:MouseEvent = null):void
		{
			switch (estado){
				case false:
					estado = true;
					TweenMax.to(mascara_des, 0.3, {ease:Bounce.easeOut, scaleY:1});
					break;
				case true:
					estado = false;
					TweenMax.to(mascara_des, 0.3, {ease:Bounce.easeOut, scaleY:0});
					break;
			}
		}
		
		public function actualizaTexto (valor:String):void
		{
			ruta_mc.ruta_txt.text = valor;
		}
		
		private function handle_lookClick( e:ItemLookBoxEvent ):void
		{
			clic();
			dispatchEvent( new ItemLookBoxEvent(ItemLookBoxEvent.ON_LOOK_CLICK) );
			
		}
	}
}